Description:
C#
allows you to use the FlagsAttribute to mark an enumeration as containing bit-mask flags. In this case, you should
specify the FlagsAttribute.
Incorrect:
class PersistentObject {
enum State {
Dirty = 0x10,
Deteriorated = 0x20,
Locked = 0x40,
Pinned = 0x80
};
int state;
void setDirty() {
state |= (int)State.Dirty;
}
}
Correct:
class PersistentObject {
[Flags]
enum State {
Dirty = 0x10,
Deteriorated = 0x20,
Locked = 0x40,
Pinned = 0x80
};
int state;
void setDirty() {
state |= State.Dirty;
}
}